package com.example.wangning.mycarofcountry.recommend;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.example.wangning.mycarofcountry.R;
import com.example.wangning.mycarofcountry.recommend.evaluating.EvaluatingFragment;
import com.example.wangning.mycarofcountry.recommend.journalism.JournalismFragment;
import com.example.wangning.mycarofcountry.recommend.newest.NewestFragment;
import com.example.wangning.mycarofcountry.recommend.technology.TechnologyFragment;
import com.example.wangning.mycarofcountry.recommend.vehicle.VehicleFragment;

import java.util.ArrayList;

/**
 * Created by dllo on 16/1/6.
 */
public class RecommendAdapter extends FragmentPagerAdapter{
    private ArrayList<Fragment> datas;
    private Context context;
    String[] titles = {"最新","新闻","评测","快报","技术"};
    public RecommendAdapter(FragmentManager fm,Context context) {
        super(fm);
        this.context = context;
        datas = new ArrayList<Fragment>();
        datas.add(new NewestFragment());
        datas.add(new JournalismFragment());
        datas.add(new EvaluatingFragment());
        datas.add(new VehicleFragment());
        datas.add(new TechnologyFragment());
    }

    @Override
    public Fragment getItem(int position) {
        return datas.get(position);
    }

    @Override
    public int getCount() {
        return datas.size();
    }


    public View getTabView(int position){
        View view = LayoutInflater.from(context).inflate(R.layout.tab,null);
        TextView textView = (TextView) view.findViewById(R.id.tv);
        textView.setText(titles[position]);
        return view;
    }
}
